package org.hpm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.hpm.entity.HpmCategory;
import org.hpm.mapper.HpmCategoryMapper;
import org.hpm.service.IHpmCategoryService;
import org.hpm.vo.HpmCategoryVO;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 商品分类表
 * @author: jacklin
 * @date: 2021-12-02
 * @version: V1.0
 */
@Service
public class HpmCategoryServiceImpl extends ServiceImpl<HpmCategoryMapper, HpmCategory> implements IHpmCategoryService {

    @Resource
    private  HpmCategoryMapper hpmCategoryMapper;

    @Override
    public List<HpmCategory> queryAllRootLevelCategory() {
        LambdaQueryWrapper<HpmCategory> categoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
        categoryLambdaQueryWrapper.eq(HpmCategory::getType, 1);
        return hpmCategoryMapper.selectList(categoryLambdaQueryWrapper);
    }

    @Override
    public List<HpmCategoryVO> querySubCategoryList(Integer rootCatId) {
        return hpmCategoryMapper.getSubCatList(rootCatId);
    }
}
